From dfa10e3527f2ca47782f6418cc935c73c00a22d7 Mon Sep 17 00:00:00 2001 From: robertl Date: Wed, 15 Jan 2003 17:02:31 +0000 Subject: [PATCH] Add shortname support for Garmin Mapsource. --- mapsource.c | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/mapsource.c b/mapsource.c index 5d58fdbbc..1458c387a 100644 --- a/mapsource.c +++ b/mapsource.c @@ -213,7 +213,9 @@ mps_read(void) static void mps_waypt_pr(const waypoint *wpt) { - int reclen = 87 + strlen(wpt->shortname) + strlen(wpt->description); + char *src; + char *ident; + int reclen; char zbuf[100]; char ffbuf[100]; char display = 1; @@ -221,6 +223,14 @@ mps_waypt_pr(const waypoint *wpt) int lat = wpt->position.latitude.degrees / 180.0 * 2147483648.0; int lon = wpt->position.longitude.degrees / 180.0 * 2147483648.0; + if(wpt->description) src = wpt->description; + if(wpt->notes) src = wpt->notes; + ident = global_opts.synthesize_shortnames ? + mkshort(src) : + wpt->shortname; + + reclen = 87 + strlen(ident) + strlen(wpt->description); + memset(zbuf, 0, sizeof(zbuf)); memset(ffbuf, 0xff, sizeof(ffbuf)); @@ -229,7 +239,7 @@ mps_waypt_pr(const waypoint *wpt) le_write32(&reclen, reclen); fwrite(&reclen, 4, 1, mps_file_out); fwrite("W", 1, 1, mps_file_out); - fputs(wpt->shortname, mps_file_out); + fputs(ident, mps_file_out); fwrite(zbuf, 1, 1, mps_file_out); fwrite(zbuf, 9, 1, mps_file_out); fwrite(ffbuf, 12, 1, mps_file_out); @@ -253,6 +263,11 @@ mps_waypt_pr(const waypoint *wpt) void mps_write(void) { + int short_length = 10; + + setshort_length(short_length); + setshort_whitespace_ok(0); + fwrite(mps_hdr, sizeof(mps_hdr), 1, mps_file_out); waypt_disp_all(mps_waypt_pr); fwrite(mps_ftr, sizeof(mps_ftr), 1, mps_file_out); -- 2.30.2